package Xenia;

import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.SwingConstants;


import java.awt.FlowLayout;
import java.awt.event.*;

import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;







public class StartWindowInterface extends JFrame
{
	private JButton buttonNewSnipper;
	
	
	
	public StartWindowInterface()
	{
		super("Auction Sniper Form");
		setLayout(new FlowLayout());
		
		buttonNewSnipper = new JButton("Join");
		buttonNewSnipper.setToolTipText("Start Bidding..");
		buttonNewSnipper.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
		buttonNewSnipper.setFocusable(false);
		buttonNewSnipper.addActionListener(new EnableButton());
		add(buttonNewSnipper);
		//buttonNewSnipper.setAlignmentX(RIGHT_ALIGNMENT);
		buttonNewSnipper.setVerticalAlignment(SwingConstants.BOTTOM);
		
		
		JMenuBar menubar = new JMenuBar();
		JMenu new_item = new JMenu("New Item");
		JMenu user_history = new JMenu ("User's History");
		
		menubar.add(new_item);
		menubar.add(user_history);
		setJMenuBar(menubar);
		
		JMenuItem newItem = new JMenuItem("Add");
		new_item.add(newItem);
		newItem.addActionListener(new EnableMenuAdd());
		
		JMenuItem showHistory = new JMenuItem("Show User's History");
		user_history.add(showHistory);
		showHistory.addActionListener(new EnableMenuHistory());
		
		

	}
	
	

	
	
	public class EnableButton implements ActionListener
	{
		
		public void actionPerformed(ActionEvent e)
		{
			NewSniperWindow w = new NewSniperWindow();
			//w.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
			w.setSize(400, 300);
			w.setVisible(true);
		}
	}
	
	public class EnableMenuAdd implements ActionListener
	{
		
		public void actionPerformed (ActionEvent e)
		{
		 AddItem w = new AddItem();
		 //w.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		 w.setSize(200, 100);
		 w.setVisible(true);
		 
		}
	}
	
	public class EnableMenuHistory implements ActionListener
	{
		
		public void actionPerformed (ActionEvent e)
		{
			UsersHistory w = new UsersHistory();
			//w.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
			w.setSize(700,300);
			w.setVisible(true);
		}
	}
}